Public Class frmCountries

    Dim dt As New DataTable()

    Private Sub btnSaveCountries_Click(sender As System.Object, e As System.EventArgs) Handles btnSaveCountries.Click

        Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=MEGACITIES.MDB"
        Dim sqlStr As String = "SELECT * FROM Countries "

        Dim changes As Integer
        Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
        Dim commandBuilder As New OleDb.OleDbCommandBuilder(dataAdapter)

        commandBuilder.GetUpdateCommand()
        Try
            changes = dataAdapter.Update(dt)
            If changes > 0 Then
                MessageBox.Show(changes & " changed rows.")
            Else
                MessageBox.Show("No changes made.")
            End If
        Catch ex As OleDb.OleDbException
            MessageBox.Show(String.Format("Could not complete save: {0}", ex.Message))
        Finally
            dataAdapter.Dispose()
        End Try
    End Sub

    Private Sub frmCountries_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'boilerplate to populate the dropdown list
        Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=MEGACITIES.MDB"
        Dim sqlStr As String = "SELECT * FROM Countries"
        Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
        dataAdapter.Fill(dt)
        dataAdapter.Dispose()
        dgvData.DataSource = dt
    End Sub



End Class